package net.zjitc.servlet.product;

import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProduceServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by Administrator on 2017/10/30.
 */
@WebServlet(name = "EditPageUIServlet",urlPatterns = "/editPageUIServlet")
public class EditPageUIServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //保存页码
        String currentPage = request.getParameter("currentPage");

        //查询当前的商品
        String str = request.getParameter("pid");
        int pid = Integer.valueOf(str); //字符串转整形
        ProductService service = new ProduceServiceImpl();
        Product p = service.findById(pid);
        request.setAttribute("p",p);
        request.setAttribute("currnetPage",currentPage);
        request.getRequestDispatcher("/product/edit.jsp").forward(request,response);
    }
}
